<template>
  <div class="app-container">
<!--    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="入库危险废物名称" prop="wxfwjcrktzName">
        <el-input
          v-model="queryParams.wxfwjcrktzName"
          placeholder="请输入入库危险废物名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="种类" prop="wxfwjcrktzZl">
        <el-input
          v-model="queryParams.wxfwjcrktzZl"
          placeholder="请输入种类"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="危险特性" prop="wxfwjcrktzTx">
        <el-input
          v-model="queryParams.wxfwjcrktzTx"
          placeholder="请输入危险特性"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="类别" prop="wxfwjcrktzLb">
        <el-input
          v-model="queryParams.wxfwjcrktzLb"
          placeholder="请输入类别"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数量" prop="wxfwjcrktzNum">
        <el-input
          v-model="queryParams.wxfwjcrktzNum"
          placeholder="请输入数量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="暂存库号" prop="wxfwjcrktzZckCode">
        <el-input
          v-model="queryParams.wxfwjcrktzZckCode"
          placeholder="请输入暂存库号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="送交人" prop="wxfwjcrktzSjr">
        <el-input
          v-model="queryParams.wxfwjcrktzSjr"
          placeholder="请输入送交人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收人" prop="wxfwjcrktzJsr">
        <el-input
          v-model="queryParams.wxfwjcrktzJsr"
          placeholder="请输入接收人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收时间" prop="wxfwjcrktzJcTime">
        <el-input
          v-model="queryParams.wxfwjcrktzJcTime"
          placeholder="请输入接收时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库日期" prop="wxfwjcrktzRkTime">
        <el-input
          v-model="queryParams.wxfwjcrktzRkTime"
          placeholder="请输入入库日期"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库视频" prop="wxfwjcrktzRkVideo">
        <el-input
          v-model="queryParams.wxfwjcrktzRkVideo"
          placeholder="请输入入库视频"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="责任人" prop="wxfwjcrktzPerson">
        <el-input
          v-model="queryParams.wxfwjcrktzPerson"
          placeholder="请输入责任人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="责任人身份证" prop="wxfwjcrktzIdCard">
        <el-input
          v-model="queryParams.wxfwjcrktzIdCard"
          placeholder="请输入责任人身份证"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>-->

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="small"
          @click="handleAdd"
          v-hasPermi="['solidDispose:wxfwjcrktzInfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="small"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['solidDispose:wxfwjcrktzInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="small"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['solidDispose:wxfwjcrktzInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="small"
		  :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['solidDispose:wxfwjcrktzInfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="wxfwjcrktzInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="危险废物接收企业入库台帐ID" align="center" prop="wxfwjcrktzId" />-->
      <el-table-column label="入库危险废物名称" align="center" prop="wxfwjcrktzName" />
      <el-table-column :formatter="typeFormat" label="种类" align="center" prop="wxfwjcrktzZl" />
      <el-table-column :formatter="typeFormat_tx" label="危险特性" align="center" prop="wxfwjcrktzTx" />
      <el-table-column  :formatter="typeFormat_lb" label="类别" align="center" prop="wxfwjcrktzLb" />
      <el-table-column label="数量" align="center" prop="wxfwjcrktzNum" />
<!--      <el-table-column label="暂存库号" align="center" prop="wxfwjcrktzZckCode" />-->
      <el-table-column label="送交人" align="center" prop="wxfwjcrktzSjr" />
      <el-table-column label="接收人" align="center" prop="wxfwjcrktzJsr" />
<!--      <el-table-column label="接收时间" align="center" prop="wxfwjcrktzJcTime" />-->
      <el-table-column label="入库日期" align="center" prop="wxfwjcrktzRkTime" />
<!--      <el-table-column label="入库视频" align="center" prop="wxfwjcrktzRkVideo" />-->
      <el-table-column label="责任人" align="center" prop="wxfwjcrktzPerson" />
      <el-table-column label="责任人身份证" align="center" prop="wxfwjcrktzIdCard" />
<!--      <el-table-column label="备注" align="center" prop="remark" />-->
<!--      <el-table-column label="冗余字段" align="center" prop="other" />-->
<!--      <el-table-column label="冗余字段" align="center" prop="otherOne" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="small"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['solidDispose:wxfwjcrktzInfo:edit']"
          >修改</el-button>
          <el-button
            size="small"
            @click="handleDelete(scope.row)"
            v-hasPermi="['solidDispose:wxfwjcrktzInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改危险废物接收企业入库台帐对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" class="clearfix " label-width="140px">
        <el-form-item label="入库危险废物名称" prop="wxfwjcrktzName">
          <el-input v-model="form.wxfwjcrktzName" placeholder="请输入入库危险废物名称" />
        </el-form-item>
        <el-form-item label="种类" prop="wxfwjcrktzZl">
          <el-select v-model="form.wxfwjcrktzZl" placeholder="请选择">
            <el-option
              v-for="dict in typeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="危险特性" prop="wxfwjcrktzTx">
          <el-select v-model="form.wxfwjcrktzTx" placeholder="请选择">
            <el-option
              v-for="dict in typeOptions_tx"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="类别" prop="wxfwjcrktzLb">
          <el-select v-model="form.wxfwjcrktzLb" placeholder="请选择">
            <el-option
              v-for="dict in typeOptions_lb"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="数量" prop="wxfwjcrktzNum" type="number">
          <el-input v-model="form.wxfwjcrktzNum" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="暂存库号" prop="wxfwjcrktzZckCode">
          <el-input v-model="form.wxfwjcrktzZckCode" placeholder="请输入暂存库号" />
        </el-form-item>
        <el-form-item label="送交人" prop="wxfwjcrktzSjr">
          <el-input v-model="form.wxfwjcrktzSjr" placeholder="请输入送交人" />
        </el-form-item>
        <el-form-item label="接收人" prop="wxfwjcrktzJsr">
          <el-input v-model="form.wxfwjcrktzJsr" placeholder="请输入接收人" />
        </el-form-item>
        <el-form-item label="接收时间" prop="wxfwjcrktzJcTime">
          <el-date-picker v-model="form.wxfwjcrktzJcTime" clearable
                          placeholder="选择接收时间"
                          size="small"
                          style="width:100%"
                          type="date"
                          value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="入库日期" prop="wxfwjcrktzRkTime">
          <el-date-picker v-model="form.wxfwjcrktzRkTime" clearable
                          placeholder="选择入库日期"
                          size="small"
                          style="width:100%"
                          type="date"
                          value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="入库视频" prop="wxfwjcrktzRkVideo">
          <VideoUpload v-model="form.wxfwjcrktzRkVideo" placeholder="请输入入库视频" />
        </el-form-item>
        <el-form-item label="责任人" prop="wxfwjcrktzPerson">
          <el-input v-model="form.wxfwjcrktzPerson" placeholder="请输入责任人" />
        </el-form-item>
        <el-form-item label="责任人身份证" prop="wxfwjcrktzIdCard">
          <el-input v-model="form.wxfwjcrktzIdCard" placeholder="请输入责任人身份证" />
        </el-form-item>
<!--        <el-form-item label="删除标志" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="冗余字段" prop="other">
          <el-input v-model="form.other" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="冗余字段" prop="otherOne">
          <el-input v-model="form.otherOne" type="textarea" placeholder="请输入内容" />
        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer tianjie_button" style="text-align: center;">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listWxfwjcrktzInfo, getWxfwjcrktzInfo, delWxfwjcrktzInfo, addWxfwjcrktzInfo, updateWxfwjcrktzInfo, exportWxfwjcrktzInfo } from "@/api/solidDispose/wxfwjcrktzInfo";
import {validatetoTwoPoint,validatePhoneTwo,validateIdNo,validateEMail} from "@/api/validate/validate";


export default {
  name: "WxfwjcrktzInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 危险废物接收企业入库台帐表格数据
      wxfwjcrktzInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        wxfwjcrktzName: null,
        wxfwjcrktzZl: null,
        wxfwjcrktzTx: null,
        wxfwjcrktzLb: null,
        wxfwjcrktzNum: null,
        wxfwjcrktzZckCode: null,
        wxfwjcrktzSjr: null,
        wxfwjcrktzJsr: null,
        wxfwjcrktzJcTime: null,
        wxfwjcrktzRkTime: null,
        wxfwjcrktzRkVideo: null,
        wxfwjcrktzPerson: null,
        wxfwjcrktzIdCard: null,
        other: null,
        otherOne: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        wxfwjcrktzName: [
          {required: true, message: "名称不能为空", trigger: "blur"}
        ],
        wxfwjcrktzIdCard: [
          {required: true,validator:validateIdNo,trigger: "blur"}
        ],
      },
      typeOptions:[],
      typeOptions_tx:[],
      typeOptions_lb:[],
    };
  },
  created() {
    this.getDicts("wxfwxt").then(response => {
      this.typeOptions = response.data;
    });
    this.getDicts("wxtx").then(response => {
      this.typeOptions_tx = response.data;
    });
    this.getDicts("wxfwlb").then(response => {
      this.typeOptions_lb = response.data;
    });
    this.getList();
  },
  methods: {
    typeFormat(row, column) {
      return this.selectDictLabel(this.typeOptions, row.wxfwjcrktzZl);
    },
    typeFormat_tx(row, column) {
      return this.selectDictLabel(this.typeOptions_tx, row.wxfwjcrktzTx);
    },
    typeFormat_lb(row, column) {
      return this.selectDictLabel(this.typeOptions_lb, row.wxfwjcrktzLb);
    },
    /** 查询危险废物接收企业入库台帐列表 */
    getList() {
      this.loading = true;
      listWxfwjcrktzInfo(this.queryParams).then(response => {
        this.wxfwjcrktzInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        wxfwjcrktzId: null,
        wxfwjcrktzName: null,
        wxfwjcrktzZl: null,
        wxfwjcrktzTx: null,
        wxfwjcrktzLb: null,
        wxfwjcrktzNum: null,
        wxfwjcrktzZckCode: null,
        wxfwjcrktzSjr: null,
        wxfwjcrktzJsr: null,
        wxfwjcrktzJcTime: null,
        wxfwjcrktzRkTime: null,
        wxfwjcrktzRkVideo: null,
        wxfwjcrktzPerson: null,
        wxfwjcrktzIdCard: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        other: null,
        otherOne: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.wxfwjcrktzId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加危险废物接收企业入库台帐";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const wxfwjcrktzId = row.wxfwjcrktzId || this.ids
      getWxfwjcrktzInfo(wxfwjcrktzId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改危险废物接收企业入库台帐";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.wxfwjcrktzId != null) {
            updateWxfwjcrktzInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addWxfwjcrktzInfo(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const wxfwjcrktzIds = row.wxfwjcrktzId || this.ids;
      this.$confirm('是否确认删除危险废物接收企业入库台帐编号为"' + wxfwjcrktzIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delWxfwjcrktzInfo(wxfwjcrktzIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有危险废物接收企业入库台帐数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportWxfwjcrktzInfo(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
